﻿using PSE.Deployment.Engine;
using PSE.Deployment.Engine.Enums;
using PSE.Deployment.Engine.Interfaces;
using PSE.Deployment.SetupBase.UI;

namespace PSE.Deployment.SetupBase.Steps
{
    public class CheckInstalledLayers : BaseStep
    {
        public CheckInstalledLayers(IStepGroup parent)
            : base(parent)
        {
            this.Id = "CheckInstalledLayers";
            this.Description = "CheckInstalledLayers";

            this.ErrorBehavior = StepErrorBehavior.CancelParent;
            this.NavigationBehavior = StepNavigationBehavior.NextCancel;
        }

        public override void Execute()
        {
            CheckPreviouslyVersion _checkPreviouslyVersion = new CheckPreviouslyVersion();

            _checkPreviouslyVersion.CheckInstalledPrograms(!SetupMainFactory.GetInstance().Parameter.IsInstalled);

            if (_checkPreviouslyVersion.InvalidPrograms.Count > 0)
                _checkPreviouslyVersion.ShowDialog();

            SetupMainFactory.GetInstance().Parameter.HasInvalidPrograms = _checkPreviouslyVersion.InvalidPrograms.Count > 0 && _checkPreviouslyVersion.NavigationAction == null;
        }

        public override void Undo()
        {

        }
    }
}
